package com.yuyou.hxyy.gateway.security;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Component;

import com.yuyou.hxyy.service.api.entity.AuthUser;
import com.yuyou.hxyy.service.api.service.IAuthUserService;

@Component
public class UserDetailsServiceImpl implements UserDetailsService {
	@Autowired
	private IAuthUserService authUserService;

	@Override
	public UserDetails loadUserByUsername(String userName)
			throws UsernameNotFoundException {

		AuthUser user=authUserService.seleteAuthUserByAccount(userName);
		if (user == null) {
			return null;
		}
		UserDetailsImpl userDetails = new UserDetailsImpl(
				user.getUsername(), user.getPassword(), user.getUserType());
		return userDetails;
	}
}